﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace A2DFramework.ValidationService.RuleValidators
{
    public class RuleCustomValidationAttribute : RuleValidationAttribute
    {
        private CustomValidationAttribute checker;

        public RuleCustomValidationAttribute(Type validatorType, string method)
            : this(string.Empty, validatorType, method)
        { 
        }

        public RuleCustomValidationAttribute(string rule, Type validatorType, string method):base(rule)
        {
            checker = new CustomValidationAttribute(validatorType, method);
        }


        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            return checker.GetValidationResult(value, validationContext);
        }
    }
}
